﻿@model XZen.Blogger.Models.RestCall
@{
    Layout = null;
}
<!doctype html>
<html>
    <head>
        <title>easyXDM</title>
        <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="../../Rpc/api.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            var md = '@Model.MyDomain';

            var transport = new easyXDM.Rpc({
                local: "../name.html",
                swf: "../easyxdm.swf"
            },
         {
             remote: {
                 returnResponse: {},
                 returnError: {}
             },
             local: {
                 Post: function (message) {
                     var rurl = message.url;
                     if (rurl == md) {
                         //var args = JSON.parse(message);
                         Post(message, "origin");
                     }
                     else {
                         message.url = md + "/Proxy/Text/1.0?url=" + message.url;
                         Post(message, "origin");
                     }
                 },
                 Get: function (message) {
                     var rurl = message.url;
                     if (rurl == md) {
                         //var args = JSON.parse(message);
                         Get(message, "origin");
                     }
                     else {
                         message.url = md + "/Proxy/Text/1.0?url=" + message.url;
                         Get(message, "origin");
                     }
                 },
                 noOp: function () {
                     alert("Method not returning any data");
                 }
             }
         });

         function Post(args, origin) {
           //whole parameters are wrapped
            $.ajax({
                url: args.url,
                type: args.type,
                success: function (data) {
                    transport.returnResponse(data);
                },
                error: function (x, s, a) {
                    transport.returnError(x,s,a);
                }
            });
        }
        function Get(args, origin) {
            //whole parameters are wrapped
            $.ajax({
                url: args.url,
                type: args.type,
                success: function (data) {
                    transport.returnResponse(data);
                },
                error: function (x, s, a) {
                    transport.returnError(x, s, a);
                }
            });
        }
        </script>
    </head>
    <body>
        <div id="log" style="height:100px;border:1px dotted black;overflow:auto">
        </div>
    </body>
</html>
